﻿using System;
using System.Linq;
using UniMana.Utils.Controls;
using UniMana.Data;
using UniMana.Utils.Configs;

namespace UniMana.Data
{
    public class Training_StudentInfo
    {   
        #region /*Không thay đổi*/
        public bds m_bds = new bds();
        public void Save()
        {
            m_data.m_DCSave.SubmitChanges();
        }
        public void Delete()
        {
            m_bds.DeleteCurrent();
            m_data.m_DCSave.SubmitChanges();
        }
        #endregion /*Không thay đổi*/

        private DBMain m_data = new DBMain();
        #region [Properties - Thuộc tính]
        public Training_Student Properties
        {
            get { return m_bds.Current as Training_Student; }
        }
        #endregion

        public Training_StudentInfo(string DefaultKey = DefaultConfig.EMPTY_GUID)
        {
            var IQuery = m_data.m_DCSave.Training_Students.Where(tb => tb.Training_StudentKey == Guid.Parse(DefaultKey.ToString()));
            m_bds.DataSource = IQuery;
            var Row = IQuery.FirstOrDefault();
            if (Row == null)
            {
                Row = new Training_Student();
                m_bds.Add(Row);
            }
        }

    }
}
